d1004bb3250b41667b2adcc46d1090653f516a38,api-gateway/src/main/java/com/redhat/coolstore/api_gateway/ApiGatewayRoute.java,ApiGatewayRoute,configure,#,41
Before Change
.param().name("cartId").type(RestParamType.path).description("The ID of the cart to process").dataType("string").endParam()
.outType(ShoppingCart.class)
.route().id("getCartRoute")
.hystrix()
.removeHeaders("CamelHttp*")
.setBody(simple("null"))
.setHeader(Exchange.HTTP_METHOD, HttpMethods.GET)
.setHeader(Exchange.HTTP_URI, simple("http://cart-service:8080/api/cart/${header.cartId}"))
After Change
.param().name("cartId").type(RestParamType.path).description("The ID of the cart to process").dataType("string").endParam()
.outType(ShoppingCart.class)
.route().id("getCartRoute")
.hystrix().id("Cart Service (Get Cart)")
.removeHeaders("CamelHttp*")
.setBody(simple("null"))
.setHeader(Exchange.HTTP_METHOD, HttpMethods.GET)
.setHeader(Exchange.HTTP_URI, simple("http://cart-service:8080/api/cart/${header.cartId}"))
.to("http4://DUMMY")
.onFallback()
// TODO: improve fallback
.transform().constant(null)
.end()
.setHeader("CamelJacksonUnmarshalType", simple(ShoppingCart.class.getName()))
.unmarshal().json(JsonLibrary.Jackson, ShoppingCart.class)
.endRest()
.delete("/{cartId}/{itemId}/{quantity}").description("Delete items from current user's shopping cart")
.param().name("cartId").type(RestParamType.path).description("The ID of the cart to process").dataType("string").endParam()
.param().name("itemId").type(RestParamType.path).description("The ID of the item to delete").dataType("string").endParam()
.param().name("quantity").type(RestParamType.path).description("The number of items to delete").dataType("integer").endParam()
.outType(ShoppingCart.class)
.route().id("deleteFromCartRoute")
.hystrix().id("Cart Service (Delete Cart)")
.removeHeaders("CamelHttp*")
.setBody(simple("null"))
.setHeader(Exchange.HTTP_METHOD, HttpMethods.DELETE)
.setHeader(Exchange.HTTP_URI, simple("http://cart-service:8080/${header.cartId}/${header.itemId}/${header.quantity}"))
.to("http4://DUMMY")
.onFallback()
// TODO: improve fallback
.transform().constant(null)
.end()
.setHeader("CamelJacksonUnmarshalType", simple(ShoppingCart.class.getName()))
.unmarshal().json(JsonLibrary.Jackson, ShoppingCart.class)
.endRest()
.post("/{cartId}/{itemId}/{quantity}").description("Add items from current user's shopping cart")
.param().name("cartId").type(RestParamType.path).description("The ID of the cart to process").dataType("string").endParam()
.param().name("itemId").type(RestParamType.path).description("The ID of the item to add").dataType("string").endParam()
.param().name("quantity").type(RestParamType.path).description("The number of items to add").dataType("integer").endParam()
.outType(ShoppingCart.class)
.route().id("addToCartRoute")
.hystrix().id("Cart Service (Add To Cart)")
.removeHeaders("CamelHttp*")
.setBody(simple("null"))
.setHeader(Exchange.HTTP_METHOD, HttpMethods.POST)
.setHeader(Exchange.HTTP_URI, simple("http://cart-service:8080/api/cart/${header.cartId}/${header.itemId}/${header.quantity}"))